<%@ page language="java" import="java.util.*,com.zjf.entity.*" pageEncoding="utf-8" contentType="text/html;charset=utf-8"%>
<%@page import="com.zjf.dao.ArticleDao"%>
<%@page import="com.zjf.dao.impl.ArticleDaoImpl"%>
<%!
String title = "";
String content="";
 %>
<%
User loginUser = (User)session.getAttribute("loginUser");

if(loginUser==null){
	response.sendRedirect("error.jsp?id=105");
	return;
}

String idStr = request.getParameter("id");
int id = Integer.parseInt(idStr);
ArticleDao dao  = new ArticleDaoImpl();
Article article  = dao.queryArticle(id);
if(loginUser.getPermisson()<1){
	response.sendRedirect("error.jsp?id=106");
	return;
}
if(article==null){
	response.sendRedirect("error.jsp?id=107");
	return;
}
//管理员和作者本身可修改
if(loginUser.getPermisson()==2 || article.getAuthor_id()==loginUser.getId()){
	title = article.getTitle();
	content = article.getContent();
}else{
	response.sendRedirect("error.jsp?id=100");
}
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
    
    <title>modify</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<!-- editor -->
<script src="<%=request.getContextPath() %>/kindeditor/kindeditor-min.js"></script>
<script  src="<%=request.getContextPath() %>/kindeditor/en.js"></script>
		<script>
		
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create('textarea[name="cont"]', {
					resizeType : 1,
					allowPreviewEmoticons : false,
					allowImageUpload : false,
					filterMode : true
				});
			});
			
		</script>
<!-- end of editor -->
  </head>
  
  <body>
  <center>
   <div id ="wrap">
		
	

	<div id="title">修改博文</div>
		     <form action="articleModify.do?id=<%=article.getId() %>" method="post">
			 标题：<input type="text" name="title" style="width:820px" value=<%=article.getTitle() %>><br>
			   <textarea name="cont"  style="width:800px;height:500px;" ><%=article.getContent()%></textarea>
			   <input type="submit" value="提交" >
			   <input name="重置" type="reset" value="清除">
			   
			</form>
	        
	
  </div>
</center>
  </body>
</html>
